package com.lijie.ljblog.chess;

import com.lijie.ljblog.enums.ChessColorEnum;
import lombok.Data;

/**
 * @Description
 * @Author lijie
 * @Date 2022/8/26 14:38
 **/
@Data
public class ChessPoint {

    private int x;
    private int y;
    private int color;

    public static ChessPoint init(int x, int y){
        return new ChessPoint(x,y);
    }
    public static ChessPoint init(int x, int y,ChessColorEnum colorEnum){
        ChessPoint chessPoint = new ChessPoint(x, y);
        chessPoint.setColor(colorEnum.getVal());
        return chessPoint;
    }
    public ChessPoint(int x, int y){
        this.x=x;
        this.y=y;
    }
    public ChessPoint(){

    }

    public ChessColorEnum getChessColorEnum(){
        ChessColorEnum[] values = ChessColorEnum.values();
        for (ChessColorEnum delFlagEnum : values) {
            if(this.color==delFlagEnum.getVal()){
                return delFlagEnum;
            }
        }
        throw new RuntimeException("未知颜色棋子");
    }
}
